package com.sinping.qh.query.lab;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author jiahuaiqing
 * @create 2018/6/9
 */
@Data
public class LabInspectItemTreeQuery implements QueryParams,Serializable {

    private static final long serialVersionUID = -5652647517678991241L;
    private static Map<String, String> aliasMap = new HashMap<String, String>();
    private static Map<String, Operator> operatorMap = new HashMap<>();

    /**
     * 名称
     */
    private String itemName;

    /**
     * 分类
     */
    private String itemSubcategory;

    /**
     * 分类
     */
    private String itemCategory;

    private String itemLevel;
    private String id;
    private String status;
    private String itemParentId;

    static {
        aliasMap.put("itemName", "item_name");
        aliasMap.put("itemSubcategory", "item_subcategory");
        aliasMap.put("itemLevel", "item_level");
        aliasMap.put("id", "_id");
        aliasMap.put("status", "status");
        aliasMap.put("itemParentId", "item_parentid");
        aliasMap.put("itemCategory", "item_category");

        operatorMap.put("itemName", Operator.regex);
        operatorMap.put("itemSubcategory", Operator.eq);
        operatorMap.put("itemLevel", Operator.eq);
        operatorMap.put("status", Operator.eq);
        operatorMap.put("itemParentId", Operator.eq);
        operatorMap.put("itemCategory", Operator.eq);
    }

    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operatorMap.getOrDefault(fieldName, Operator.eq);
    }
}
